package pid

// 负荷跟踪控制算法结构体
type LoadTrackingControl struct {
	BasePower  float64
	MaxPower   float64
	MinPower   float64
	Adjustment float64
}

// 负荷跟踪控制方法
func (ltc *LoadTrackingControl) AdjustPower(currentPower, loadDemand float64) float64 {
	adjustedPower := currentPower + ltc.Adjustment*(loadDemand-currentPower)
	if adjustedPower > ltc.MaxPower {
		adjustedPower = ltc.MaxPower
	} else if adjustedPower < ltc.MinPower {
		adjustedPower = ltc.MinPower
	}
	return adjustedPower
}
